package team.seekers.hula.course.resource.sectionTalk.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.common.entity.PageResult;
import team.seekers.hula.course.resource.sectionTalk.entity.dto.SectionTalkAddDTO;
import team.seekers.hula.course.resource.sectionTalk.entity.dto.SectionTalkQueryDTO;
import team.seekers.hula.course.resource.sectionTalk.entity.dto.SectionTalkUpdateDTO;
import team.seekers.hula.course.resource.sectionTalk.entity.vo.SectionTalkListVO;
import team.seekers.hula.course.resource.sectionTalk.service.SectionTalkService;

/**
 * <p>
 * 回答的评论 前端控制器
 * </p>
 *
 * @author hbc
 * @since 2021-02-18
 */
@Controller
@ApiResponseBody
@RequestMapping("/section/talk")
public class SectionTalkController {

    @Autowired
    private SectionTalkService sectionTalkService;


    @PostMapping("/add")
    public void add(@RequestBody SectionTalkAddDTO addDTO){
        sectionTalkService.add(addDTO);
    }

    @GetMapping("/delete")
    public void delete(@RequestParam String id){
        sectionTalkService.delete(id);
    }


    @PostMapping("/update")
    public void update(@RequestBody SectionTalkUpdateDTO updateDTO){
        sectionTalkService.update(updateDTO);
    }

    //分页查询按照good排序
    @GetMapping("/pageOrderByGood")
    public PageResult<SectionTalkListVO> pageOrderByGood(SectionTalkQueryDTO queryDTO){
        return sectionTalkService.pageOrderByGood(queryDTO);
    }


    @GetMapping("/good")
    public void addGood(@RequestParam String sectionTalkId){
        sectionTalkService.addGood(sectionTalkId);
    }


    @GetMapping("/bad")
    public void addBad(@RequestParam String sectionTalkId){
        sectionTalkService.addBad(sectionTalkId);
    }
}

